package com.tangye.massageshop.util;

import lombok.Data;

@Data
public class Result<T> {

    /**
     * 响应码
     */
    private Integer code;

    private String message;

    private T data;

    public static Result<String> ok(){
        Result<String> result = new Result<>();
        result.setCode(200);
        result.setMessage("成功");
        return result;
    }

    public static Result<String> error(String errMsg){
        Result<String> result = new Result<>();
        result.setCode(-1);
        result.setMessage(errMsg);
        return result;
    }

    public static Result<String> error(int code ,String errMsg){
        Result<String> result = new Result<>();
        result.setCode(-1);
        result.setMessage("失败");
        result.setData(errMsg);
        return result;
    }

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("成功");
        result.setData(data);
        return result;
    }
}
